﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Royaumes_Libres.Database;

namespace Royaumes_Libres
{
    public partial class ucMenuTop : System.Web.UI.UserControl
    {
        cUsers User;

        protected void Page_Load(object sender, EventArgs e)
        {
            bool IsAdmin = false;

            if (Session[Properties.Settings.Default.ObjUser] != null)
            {
                User = (cUsers)Session[Properties.Settings.Default.ObjUser];
                if (User.Admin)
                {
                    FillMenuAdmin();
                    IsAdmin = true;
                }
            }

            if (!IsAdmin)
            {
                FillMenu();
            }
        }

        protected void FillMenu()
        {
            this.menuUserTop.Items.Clear();

            this.menuUserTop.Items.Add(new MenuItem(cText.GetText("Index"), cText.GetText("Index"), "", "index.aspx"));
            if (Session[Properties.Settings.Default.ObjUser] != null)
            {
                this.menuUserTop.Items.Add(new MenuItem(cText.GetText("Logout"), cText.GetText("Logout"), "", "logout.aspx"));
            }
            else
            {
                this.menuUserTop.Items.Add(new MenuItem(cText.GetText("Connect"), cText.GetText("Connect"), "", "login.aspx"));
                this.menuUserTop.Items.Add(new MenuItem(cText.GetText("Register"), cText.GetText("Register"), "", "register.aspx"));
            }
            this.menuUserTop.Items.Add(new MenuItem(cText.GetText("Play"), cText.GetText("Play"), "", "kingdoms.aspx"));
            this.menuUserTop.Items.Add(new MenuItem(cText.GetText("Help"), cText.GetText("Help"), "", "userhelp.aspx"));

        }

        protected void FillMenuAdmin()
        {
            this.menuUserTop.Items.Clear();

            this.menuUserTop.Items.Add(new MenuItem(cText.GetText("World"), cText.GetText("World"), "", "adminworld.aspx"));
            this.menuUserTop.Items.Add(new MenuItem(cText.GetText("WorldSet"), cText.GetText("WorldSet"), "", "adminsettingworld.aspx"));
            this.menuUserTop.Items.Add(new MenuItem(cText.GetText("Logout"), cText.GetText("Logout"), "", "logout.aspx"));

        }
    }
}